home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94b.txt / 000132_nevin@caslon _Mon Dec 5 05:58:11 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  3KB

  1. Received: from optima.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Mon, 5 Dec 1994 05:58:16 MST
  2. Received: from caslon.CS.Arizona.EDU by optima.CS.Arizona.EDU (5.65c/15) via SMTP
  3.     id AA28193; Mon, 5 Dec 1994 05:58:15 MST
  4. Received: (nevin@localhost) by caslon.CS.Arizona.EDU (8.6.7/8.6.4) id FAA00432 for icon-group@cs.arizona.edu; Mon, 5 Dec 1994 05:58:13 -0700
  5. From: Nevin Liber <nevin@caslon>
  6. Message-Id: <199412051258.FAA00432@caslon.CS.Arizona.EDU>
  7. Subject: Icon debugging tip
  8. To: icon-group@cs.arizona.edu (Icon Group)
  9. Date: Mon, 5 Dec 1994 05:58:11 -0700 (MST)
  10. X-Mailer: ELM [version 2.4 PL23]
  11. Content-Type: text
  12. Content-Length: 2193      
  13.  
  14. Since I'm currently working on a fairly large project, I thought I'd
  15. share one of the debugging tips that I'm using.
  16.  
  17.  
  18. I need to be able to control on a procedure by procedure basis which
  19. procedures should output debugging information, and which ones
  20. shouldn't.  Additionally, I want to be able to easily turn off all the
  21. embedded debugging code when I am done.
  22.  
  23.  
  24. First, I have a global variable gTfDebug, which is a table of files.
  25.  
  26. Next, given a procedure Peachfuzz(x1, x2) where I wish to write a line of
  27. debugging output every time it is invoked, I would add the following
  28. line of code to Peachfuzz:
  29.  
  30.     write(\gTfDebug[Peachfuzz], repl(" ", &level),
  31.         "Peachfuzz(", image(x1), ", ", image(x2), ")")
  32.  
  33. [Note:  the reason that I have the repl(" ", &level) is to visually
  34. show how many levels deep the procedure call is.  This has the added
  35. benefit of lining up debugging output for the same instance of a call;
  36. ie, I might want to print out the suspended or returned values.  I use
  37. image() to make sure that the debugging code never has a run time
  38. error, even if the parameters aren't exactly what was expected.]
  39.  
  40. Now, I would put the following as my first statement in main():
  41.  
  42. 1)  I want all procedures to write their debugging output to &errout:
  43.  
  44.     gTfDebug := table(&errout)
  45.  
  46. 2)  I want no debugging output:
  47.  
  48.     gTfDebug := table()
  49.  
  50. 3)  I want only Rocky() and Bullwinkle() to produce debugging output:
  51.  
  52.     gTfDebug := table()
  53.     every gTfDebug[Rocky | Bullwinkle] := &errout
  54.  
  55. 4)  I want everything except Boris() and Natasha() to produce debugging output:
  56.  
  57.     gTfDebug := table(&errout)
  58.     every gTfDebug[Boris | Natasha] := &null
  59.  
  60. Etc., etc.
  61.  
  62.  
  63. Hopefully, someone else will find this helpful!
  64. -- 
  65.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  66.                                                   ^^^ (520) after 3/95
  67.        ___    _    ____    _    ___
  68.       /   \__/ \__/    \__/ \__/   \      "Hey Rocky!
  69.       |          _|@ @ __          |      Watch me pull some intelligence
  70.        \________/ |    | \________/       out of the internet!"
  71.                __/    _/                  "But that trick never works."
  72.               /) (o _/                    "This time for sure."
  73.               \____/